#pragma once
#include <iostream>
#include <unordered_map>
#include <functional>

using work_t = std::function<void()>;
static int tasknum = 0;

void Download()
{
    std::cout << "我是一个下载任务" << std::endl;
}

void Print()
{
    std::cout << "我是一个打印任务" << std::endl;
}

void sql()
{
    std::cout << "我是一个数据库任务" << std::endl;
}

class Task
{
public:
    Task() 
    {
        InsertTask(Download);
        InsertTask(Print);
        InsertTask(sql);
    }
    ~Task()
    {}
    void InsertTask(work_t work)
    {
        tasks[tasknum++] = work;
    }
    void Execute(int wd)
    {
        tasks[wd]();
    }
private:
    std::unordered_map<int,work_t> tasks;
};

Task tm;





